/**
 * 终止选择弹窗
 * 2025-08-15 16:27:12 tzj
 * */
import {message, Modal, Row} from "antd";
import React from "react";
import {SelectAccount, SelectPerson} from "../../components/BaseComponent/forms";
import {mrhzApi} from "../../services/basic";
// import {lzApi} from "../../services/basic";
// import {ButtonExport} from "../BaseComponent/forms";
// import Dictionary from "../../services/dictionary";


class StopModal extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            visible: false,
            dataList: [],
            // 账号id
            zhid: null,
            // 员工工号
            yggh: null,
            // 账号名称
            zhmc: "",
        }
        console.log("created")
    }

    open(data) {
        this.setState({
            visible: true,
            dataList: data,
            // zhid: null,
            // yggh: null,
            // zhmc: "",
        })
    }

    handleOk = () => {
        // zhid:"75783442531"
        // yggh:"KF101"
        if (!this.state.zhid) {
            message.warning("请选择账号");
        } else if (!this.state.yggh) {
            message.warning("请选择人员");
        } else {
            const zhid = this.state.zhid;
            const yggh = this.state.yggh;
            const zhmc = this.state.zhmc;
            const obj = this.state.dataList.find(item => {
                return item.zhmc === zhmc
            })
            const params = {
                ...obj,
                zhid,
                yggh,
                zw:7
            }
            console.log(params)
            // return
            mrhzApi.mrhzJz(params).then(res => {
                if (res.code === "1") {
                    message.success("操作成功");
                    this.setState({visible: false,})
                }
            }).catch((err) => {
                console.log(err)
            })
        }
    }

    handleCancel = () => {
        this.setState({visible: false})
    }

    onFormChange = (data, e) => {
        this.setState(data)
    }

    onAccountChange = (data, e) => {
        this.setState({...data, zhmc: e.children})
    }

    render() {
        return (
            <Modal
                title="选择截止数据"
                visible={this.state.visible}
                onOk={this.handleOk}
                onCancel={this.handleCancel}
                width={1200}
                // footer={null}
            >
                <Row gutter={[15, 10]}>
                    <SelectAccount keyword="zhid" colSpan={12} onFormChange={this.onAccountChange}></SelectAccount>
                    <SelectPerson keyword="yggh" colSpan={12} label="人员" onFormChange={this.onFormChange}></SelectPerson>
                </Row>
            </Modal>
        )
    }
}

export default StopModal;